﻿//////////////////////////////////////////////////////////////////////////////
//
//  Copyright © 1998-2024 Glodon Company Limited.  All rights reserved.
//
//  Use of this software is subject to the terms of the Glodon license
//  agreement provided at the time of installation or download, or which
//  otherwise accompanies this software in either electronic or hard copy form.  
//
//////////////////////////////////////////////////////////////////////////////

// Reviewed

#pragma once

#include "GnufBase.h"
#include "GnufAnnouncementInterface.h"

namespace {
    class AnnouncementManagerImpl;
}

namespace gnuf {
    class IAnnouncementObserver;
    class Announcement;
    class LowDegreeAnnouncement;
    class MediumDegreeAnnouncement;

    class GNUF_BASE_EXPORT AnnouncementManager final 
    {
    public:
        ///\return Return the global instance.
        static AnnouncementManager * get();

        explicit AnnouncementManager();
        ~AnnouncementManager();

    public:
        ///\brief Set the maximum number of the low/medium degree announcements, to show.
        /// By default, it is 3 and 5 respectively for the low and medium degree.
        void setMaxCount(const AnnouncementType, int);
        ///\brief Get the maimum number of the low/medium degree announcements.
        int maxCount(const AnnouncementType) const;

        ///\brief Set how long to fade-in or fade-out.
        /// By default, it is 300 for both the low and medium degree.
        void setInterval(const AnnouncementType, int millisec);
        ///\brief Get how long to fade-in or fade-out.
        int interval(const AnnouncementType) const;

        ///\brief Set how long to show.
        /// By default, it is 5400 for both the low and medium degree.
        void setDuration(const AnnouncementType, int millisec);
        ///\brief Get how long to show.
        int duration(const AnnouncementType) const;
        
        ///\brief Post a low degree announcement.
        void postLowDegreeAnnouncement(const LowDegreeAnnouncement &);
        ///\brief Post a medium degree announcement.
        void postMediumDegreeAnnouncement(const MediumDegreeAnnouncement &, IAnnouncementObserver *);
        
        ///\brief Add an observer for the announcement. An observer can observe multi-announcement.
        ///\param key: the announcement's key.
        ///\param pObserver: an observer intends to observe the announcement.
        void addObserver(const std::string & key, IAnnouncementObserver * pObserver);
        ///\brief Remove the observer.
        ///\param pObserver: the observer.
        ///\param key: if the key is not empty, only remove the observer from
        ///            the announcement whose key euqals the key. Otherwise,
        ///            remove all the observers from all the observed announcements.
        void removeObserver(const IAnnouncementObserver * pObserver, const std::string & key = "");

    private:
        gcmp::OwnerPtr< ::AnnouncementManagerImpl > m_opImpl;
    };
}
